{% extends 'layout.html' %}
{% block title%}{{title}}{% endblock %}
{% block secondtitle %}{{secondtitle}}{% endblock %}
{% block content %}
<div class="wrapper-md">
    <form action="/take/" class="m-b-md">
        <div class="input-group">
            <input type="text" name="s" class="form-control input-lg" placeholder="输入关键字，目前只支持标题检索">
      <span class="input-group-btn">
        <button class="btn btn-lg btn-default" type="submit">搜索</button>
      </span>
        </div>
    </form>


    <p class="m-b-md">
        Docs.ren为您找到与“<strong>{{content}}</strong>”相关的结果约<strong>{{extra.total}}</strong>个
    </p>


    <div class="tab-container">
        {% if posts.length %}
        <div class="tab-content">

            <ul class="list-group no-borders pull-in m-b-none">

                {% for post in posts%}
                <li class="list-group-item">
                    <a href="/{{post.type}}/{{post._id.toString()}}" class="h4 text-primary m-b-sm m-t-sm block">{{post.title.replace(eval("/"+content+"/i"),'<span style="color:#dd4b39">'+content+'</span>')}}</a>
                    <p>{{post.description}}</p>
                    {% if post.tags.length%}
                    <p>
                        <span class="label bg-primary pos-rlt m-r inline wrapper-xs">
                            <i class="arrow right arrow-primary"></i> Tags:
                        </span>
                        {% for tag in post.tags%}
                            <a href="/take/?s={{tag}}" class="m-r-sm">{{tag}}</a>
                        {% endfor %}
                    </p>
                    {% endif %}
                </li>
                {%endfor%}
            </ul>
        </div>
        {% endif %}
    </div>
    <div class="text-center m-t-lg m-b-lg">
        {% if posts.length %}
        <ul class="pagination pagination-md">
            {% if extra.current > 1%}
                <li><a href="/take/?p={{extra.current-1}}&s={{content}}"><i class="fa fa-chevron-left"></i></a></li>
            {% endif %}


            {% if 1 == extra.current %}
                 <li class="active"><a href="/take/?p=1&s={{content}}">1</a></li>
            {% else %}
                 <li><a href="/take/?p=1&s={{content}}">1</a></li>
            {% endif %}

            {% for page in pagination %}
                 {% if page == extra.current %}
                    <li class="active"><a href="/take/?p={{page}}&s={{content}}">{{page}}</a></li>
                 {% else %}
                    <li><a href="/take/?p={{page}}&s={{content}}">{{page}}</a></li>
                 {% endif %}
            {% endfor %}

            {% if extra.current < extra.pagetotal - 3 %}
                <li><a href="javascript:;"><span>...</span></a></li>
            {% endif %}


            {% if extra.pagetotal > 1%}
                {% if extra.pagetotal > extra.current %}
                    <li><a href="/take/?p={{extra.pagetotal}}&s={{content}}">{{extra.pagetotal}}</a></li>
                {% else %}
                    <li class="active"><a href="/take/?p={{extra.pagetotal}}&s={{content}}">{{extra.pagetotal}}</a></li>
                {% endif %}
            {% endif %}

            {% if extra.current < extra.pagetotal %}
                <li><a href="/take/?p={{extra.current+1}}&s={{content}}"><i class="fa fa-chevron-right"></i></a></li>
            {% endif %}
        </ul>
        {% endif %}
    </div>
    </div>
{% endblock %}
